package com.ltkj.shop.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ltkj.common.log.annotation.Log;
import com.ltkj.common.log.enums.BusinessType;
import com.ltkj.common.security.annotation.RequiresPermissions;
import com.ltkj.shop.domain.ShopRestaurantMenu;
import com.ltkj.shop.service.IShopRestaurantMenuService;
import com.ltkj.common.core.web.controller.BaseController;
import com.ltkj.common.core.web.domain.AjaxResult;
import com.ltkj.common.core.utils.poi.ExcelUtil;
import com.ltkj.common.core.web.page.TableDataInfo;

/**
 * 餐饮菜品Controller
 * 
 * @author xupf
 * @date 2023-08-29
 */
@Api(tags = "餐饮菜品")
@RestController
@RequestMapping("/restMenu")
public class ShopRestaurantMenuController extends BaseController
{
    @Autowired
    private IShopRestaurantMenuService shopRestaurantMenuService;

    /**
     * 查询餐饮菜品列表
     */
    @ApiOperation("查询餐饮菜品列表")
    @RequiresPermissions("shop:restMenu:list")
    @GetMapping("/list")
    public TableDataInfo list(ShopRestaurantMenu shopRestaurantMenu)
    {
        startPage();
        List<ShopRestaurantMenu> list = shopRestaurantMenuService.selectShopRestaurantMenuList(shopRestaurantMenu);
        return getDataTable(list);
    }

    /**
     * 导出餐饮菜品列表
     */
    @ApiOperation("导出餐饮菜品列表")
    @RequiresPermissions("shop:restMenu:export")
    @Log(title = "餐饮菜品", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopRestaurantMenu shopRestaurantMenu)
    {
        List<ShopRestaurantMenu> list = shopRestaurantMenuService.selectShopRestaurantMenuList(shopRestaurantMenu);
        ExcelUtil<ShopRestaurantMenu> util = new ExcelUtil<ShopRestaurantMenu>(ShopRestaurantMenu.class);
        util.exportExcel(response, list, "餐饮菜品数据");
    }

    /**
     * 获取餐饮菜品详细信息
     */
    @ApiOperation("获取餐饮菜品详细信息")
    @RequiresPermissions("shop:restMenu:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shopRestaurantMenuService.selectShopRestaurantMenuById(id));
    }

    /**
     * 新增餐饮菜品
     */
    @ApiOperation("新增餐饮菜品")
    @RequiresPermissions("shop:restMenu:add")
    @Log(title = "餐饮菜品", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopRestaurantMenu shopRestaurantMenu)
    {
        return shopRestaurantMenuService.insertShopRestaurantMenu(shopRestaurantMenu);
    }

    /**
     * 修改餐饮菜品
     */
    @ApiOperation("修改餐饮菜品")
    @RequiresPermissions("shop:restMenu:edit")
    @Log(title = "餐饮菜品", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopRestaurantMenu shopRestaurantMenu)
    {
        return toAjax(shopRestaurantMenuService.updateShopRestaurantMenu(shopRestaurantMenu));
    }

    /**
     * 删除餐饮菜品
     */
    @ApiOperation("删除餐饮菜品")
    @RequiresPermissions("shop:restMenu:remove")
    @Log(title = "餐饮菜品", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shopRestaurantMenuService.deleteShopRestaurantMenuByIds(ids));
    }
}
